home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / HardBlocks < prev    next >
Encoding:
Text File  |  1988-08-01  |  17.0 KB  |  386 lines

  1.  
  2. Preliminary Hardblocks and FileSysRes Docs for Future
  3.     Commodore and Third Party Hard Disk Devices
  4.          (not supported by 2090 or 2090A)
  5. =====================================================
  6.         Copyright 1988 Commodore-Amiga, Inc.
  7.  
  8. hardblocks.h
  9.  
  10. This file describes blocks of data that exist on a hard disk
  11. to describe that disk.  They are not generically accessable to
  12. the user as they do not appear on any DOS drive.  The blocks
  13. are tagged with a unique identifier, checksummed, and linked
  14. together.
  15.  
  16. The four block types currently defined are RigidDiskBlock,
  17. BadBlockBlock, PartitionBlock, FileSysHeaderBlock, and
  18. LoadSegBlock.
  19.  
  20. The root of these blocks is the RigidDiskBlock.
  21. The RigidDiskBlock must exist on the disk within the first
  22. RDB_LOCATION_LIMIT blocks.  This inhibits the use of the zero
  23. cylinder in an AmigaDOS partition: although it is strictly
  24. possible to store the RigidDiskBlock data in the reserved
  25. area of a partition, this practice is discouraged since the
  26. reserved blocks of a partition are overwritten by "Format",
  27. "Install", "DiskCopy", etc.  The recommended disk layout,
  28. then, is to use the first cylinder(s) to store all the drive
  29. data specified by these blocks: i.e. partition descriptions,
  30. file system load images, drive bad block maps, spare blocks,
  31. etc.  This allocation range is described in the RigidDiskBlock.
  32.  
  33. The RigidDiskBlock points to bad block, partition, file system
  34. and drive initialization description blocks.  The bad block
  35. format is simply lists of pairs describing bad blocks and their
  36. replacements.
  37.  
  38. The drive initialization description blocks are LoadSegBlock
  39. blocks that are loaded at boot time to perform drive-specific
  40. initialization when called with parameters both "C" style on
  41. the stack, and in assembler registers as follows:
  42.     d0 = DriveInit(lun,rdb,ior)(d0/a0/a1)
  43. where lun is the SCSI logical unit number (needed to construct
  44. SCSI commands), rdb is an image of the RigidDiskBlock and
  45. cannot be altered, and ior is a standard IO request block that
  46. can be used to access the drive with synchronous DoIO() calls.
  47. The result of DriveInit is either -1, 0, or 1.  -1 reports an
  48. error occurred and drive initialization cannot continue, zero
  49. reports success.  In both cases, the code is unloaded.  1
  50. reports success, and causes the code to be kept loaded.
  51. Furthermore, this resident code is to be called whenever a 
  52. reset is detectected on the SCSI bus.
  53.  
  54.  
  55. The FileSysHeaderBlock entries contain code for alternate
  56. file handlers to be used by partitions that specify them.
  57. There are several strategies that can be used to determine
  58. which of them to load.  The most robust would scan all drives
  59. for those that are both required by partitions and have the
  60. highest fhb_Version, and load those.  Whatever method is used,
  61. the loaded file handlers are added to the exec resource
  62. FileSystem.resource, where they are used as needed to mount
  63. disk partitions.
  64.  
  65. The PartitionBlock entries contains most of the data necessary
  66. to add each device to the system.  They replace the Mount &
  67. DEVS:MountList mechanism for adding these devices.  The only
  68. items required by the expansion.library MakeDosNode function
  69. which are not in this partition block are the exec device
  70. name and unit, which is expected to be known by the reader of
  71. the block.  The file system to be used is specified in the
  72. pb_Environment.  If it is not the default file system (i.e.
  73. 'DOS\0'), the node created by MakeDosNode is modified as
  74. specified in a FileSystem.resource's FileSysEntry before adding
  75. it to the dos list.
  76.  
  77. Though only 512 byte blocks are currently supported by the
  78. file system, this proposal tries to be forward-looking by
  79. making the block size explicit, and by using only the first
  80. 256 bytes for all blocks but the LoadSeg data.
  81.  
  82.  
  83.     RigidDiskBlock
  84.    rdb_ID         == 'RDSK'
  85.    rdb_SummedLongs      == 64
  86.    rdb_ChkSum      block checksum (longword sum to zero)
  87.    rdb_HostID      SCSI Target ID of host
  88.             This is the initiator ID of the creator of this
  89.             RigidDiskBlock.  It is intended that
  90.             modification of the RigidDiskBlock, or of any
  91.             of the blocks pointed to by it, by another
  92.             initiator (other than the one specified here)
  93.             be allowed only after a suitable warning.  The
  94.             user is then expected to perform an audio
  95.             lock out ("Hey, is anyone else setting up SCSI
  96.             stuff on this bus?").  The rdb_HostID may
  97.             become something other than the initiator ID
  98.             when connected to a real network: that is an
  99.             area for future standardization.
  100.    rdb_BlockBytes      size of disk blocks
  101.             This must be 512 for a disk with any
  102.             AmigaDOS partitions on it.
  103.    rdb_Flags      longword of flags
  104.        RDBF._LAST          no disks exist to be configured after this
  105.                 one on this controller.
  106.        RDBF._LASTLUN       no LUNs exist to be configured greater
  107.                 than this one at this SCSI Target ID
  108.        RDBF._LASTTID       no Target IDs exist to be configured
  109.                 greater than this one on this SCSI bus
  110.        RDBF._DISKID       rdb_Disk... identification variables below
  111.                 contain valid data.
  112.        RDBF._CTRLRID       rdb_Controller... identification variables
  113.                 below contain valid data.
  114.  
  115.       These fields point to other blocks on the disk which are not
  116.       a part of any filesystem.
  117.  
  118.    rdb_BadBlockList   optional bad block list
  119.             A singly linked list of blocks of type
  120.             PartitionBlock
  121.    rdb_PartitionList   optional first partition block
  122.             A singly linked list of blocks of type
  123.             PartitionBlock
  124.    rdb_FileSysHeaderList   optional file system header block
  125.             A singly linked list of blocks of type
  126.             FileSysHeaderBlock
  127.    rdb_DriveInit      optional drive-specific init code
  128.             A songly linked list of blocks of type
  129.             LoadSegBlock containing initialization code.
  130.             Called as DriveInit(lun,rdb,ior)(d0/a0/a1).
  131.    rdb_Reserved1      set to $ffffffffs
  132.             These are reserved for future block lists.
  133.             Since NULL for block lists is $ffffffff, these
  134.             reserved entries must be set to $ffffffff.
  135.  
  136.       These fields describe the physical layout of the drive.
  137.  
  138.    rdb_Cylinders      number of drive cylinders
  139.    rdb_Sectors      sectors per track
  140.    rdb_Heads      number of drive heads
  141.    rdb_Interleave      interleave
  142.             This drive interleave is independent from, and
  143.             unknown to, the DOS's understanding of
  144.             interleave as set in the partition's
  145.             environment vector.
  146.    rdb_Park      landing zone cylinder
  147.    rdb_Reserved2      set to zeros
  148.  
  149.       These fields are intended for ST506 disks.  They are generally
  150.       unused for SCSI devices and set to zero.
  151.  
  152.    rdb_WritePreComp   starting cylinder: write precompensation
  153.    rdb_ReducedWrite   starting cylinder: reduced write current
  154.    rdb_StepRate      drive step rate
  155.    rdb_Reserved3      set to zeros
  156.  
  157.       These fields are used while partitions are set up to constrain
  158.       the partitionable area and help describe the relationship
  159.       between the drive's logical and physical layout. 
  160.  
  161.    rdb_RDBlocksLo      low block of the range allocated for
  162.             blocks described here.  Replacement blocks
  163.             for bad blocks may also live in this range.
  164.    rdb_RDBlocksHi      high block of this range (inclusive)
  165.    rdb_LoCylinder      low cylinder of partitionable disk area
  166.             Blocks described by this include file will
  167.             generally be found in cylinders below this one.
  168.    rdb_HiCylinder      high cylinder of partitionable data area
  169.             Usually rdb_Cylinders-1.
  170.    rdb_CylBlocks      number of blocks available per cylinder
  171.             This may be rdb_Sectors*rdb_Heads, but a SCSI
  172.             disk that reserves one block per cylinder for
  173.             bad block mapping uses rdb_Sectors*rdb_Heads-1.
  174.    rdb_AutoParkSeconds   The number of seconds to wait before parking
  175.             drive heads automatically.  If zero, this
  176.             feature is not desired.
  177.    rdb_Reserved4      set to zeros
  178.  
  179.       These fields are of the form available from a SCSI Identify
  180.       command.  Their purpose is to help the user identify the
  181.       disk during setup.  Entries exist for both controller and
  182.       disk for non-embedded SCSI disks.
  183.  
  184.    rdb_DiskVendor      The vendor name of the disk
  185.    rdb_DiskProduct      The product name of the disk
  186.    rdb_DiskRevision   The revision code of the disk
  187.    rdb_ControllerVendor   The vendor name of the disk controller
  188.    rdb_ControllerProduct   The product name of the disk controller
  189.    rdb_ControllerRevision   The revision code of the disk controller
  190.    rdb_Reserved5
  191.  
  192.     BadBlockBlock
  193.       The end of data occurs when bbb_Next is null ($ffffffff), and
  194.       the summed data is exhausted.
  195.  
  196.    bbb_ID         == 'BADB'
  197.    bbb_SummedLongs      size of this checksummed structure
  198.             Note that this is not 64 like most of the other
  199.             structures.  This is the number of valid longs
  200.             in this image, and can be from 6 to
  201.             rdb_BlockBytes/4.  The latter is the best size
  202.             for all intermediate blocks.
  203.    bbb_ChkSum      block checksum (longword sum to zero)
  204.    bbb_HostID      SCSI Target ID of host
  205.             This describes the initiator ID for the creator
  206.             of these blocks.  (see the rdb_HostID
  207.             discussion)
  208.    bbb_Next      block number of the next BadBlockBlock
  209.    bbb_Reserved
  210.    bbb_BlockPairs      pairs of block remapping information
  211.             The data starts here and continues as long as
  212.             indicated by bbb_SummedLongs-6: e.g. if
  213.             bbb_SummedLongs is 128 (512 bytes), 61 pairs
  214.             are described here.
  215.  
  216.     PartitionBlock
  217.        Note that while reading these blocks you may encounter partitions
  218.        that are not to be mounted because the pb_HostID does not match,
  219.        or because the pb_DriveName is in use and no fallback strategy
  220.        exists, or because PBF._NOMOUNT is set.  They may be mounted but
  221.        not made bootable because PBF._BOOTABLE is not set.
  222.  
  223.    pb_ID         == 'PART'
  224.    pb_SummedLongs      == 64
  225.    pb_ChkSum      block checksum (longword sum to zero)
  226.    pb_HostID      SCSI Target ID of host
  227.             This describes the initiator ID for the owner
  228.             of this partition.  (see the rdb_HostID
  229.             discussion)
  230.    pb_Next         block number of the next PartitionBlock
  231.    pb_Flags      see below for defines
  232.        PBF._BOOTABLE       this partition is intended to be bootable
  233.                 (e.g. expected directories and files exist)
  234.    pb_Reserved1
  235.  
  236.    pb_DevFlags      preferred flags for OpenDevice
  237.    pb_DriveName      preferred DOS device name: BSTR form
  238.             This name is not to be used if it is already
  239.             in use.
  240.  
  241.       pb_Reserved2 will always be at least 4 longwords so that
  242.       the ram image of this record may be converted to the parameter
  243.       packet to the expansion.library function MakeDosNode
  244.  
  245.    pb_Reserved2      filler to 32 longwords
  246.  
  247.       The specification of the location of the partition is one of
  248.       the components of the environment, below.  If possible,
  249.       describe the partition in a manner that tells the DOS about
  250.       the physical layout of the partition: specifically, where the
  251.       cylinder boundaries are.  This allows the DOS's smart block
  252.       allocation strategy to work.
  253.  
  254.    pb_Environment      environment vector for this partition
  255.        de_TableSize       size of Environment vector
  256.        de_SizeBlock       == 128
  257.        de_SecOrg          == 0
  258.        de_Surfaces          number of heads
  259.                 (see layout discussion above)
  260.        de_SectorPerBlock       == 1
  261.        de_BlocksPerTrack       blocks per track
  262.                 (see layout discussion above)
  263.        de_Reserved          DOS reserved blocks at start of partition.
  264.                 Must be >= 1.  2 is recommended.
  265.        de_PreAlloc          DOS reserved blocks at end of partition
  266.                 Valid only for filesystem type DOS^A (the
  267.                 fast file system).  Zero otherwise.
  268.        de_Interleave       DOS interleave
  269.                 Valid only for filesystem type DOS^@ (the
  270.                 old file system).  Zero otherwise.
  271.        de_LowCyl          starting cylinder
  272.        de_HighCyl          max cylinder
  273.        de_NumBuffers       initial # DOS of buffers. 
  274.        de_BufMemType       type of mem to allocate for buffers
  275.                 The second argument to AllocMem().
  276.        de_MaxTransfer       max number of bytes to transfer at a time
  277.        de_Mask          address mask to block out certain memory
  278.                 $00ffffff for DMA devices.
  279.        de_BootPri          Boot priority for autoboot
  280.                 Suggested value: zero.  Keep less than
  281.                 five, so it won't override a boot floppy.
  282.        de_DosType          ASCII string showing filesystem type;
  283.                 DOS^@ ($444F5300) is old filesystem,
  284.                 DOS^A ($444F5301) is fast file system.
  285.    pb_EReserved      reserved for future environment vector
  286.  
  287.     FileSysHeaderBlock
  288.    fhb_ID         == 'FSHD'
  289.    fhb_SummedLongs      == 64
  290.    fhb_ChkSum      block checksum (longword sum to zero)
  291.    fhb_HostID      SCSI Target ID of host
  292.             This describes the initiator ID for the creator
  293.             of this block.  (see the rdb_HostID
  294.             discussion)
  295.    fhb_Next      block number of next FileSysHeaderBlock
  296.    fhb_Flags      see below for defines
  297.    fhb_Reserved1
  298.  
  299.       The following information is used to construct a FileSysEntry
  300.       node in the FileSystem.resource.
  301.  
  302.    fhb_DosType      file system description
  303.             This is matched with a partition environment's
  304.             de_DosType entry.
  305.    fhb_Version      release version of this load image
  306.             Usually MSW is version, LSW is revision.
  307.    fhb_PatchFlags      patch flags
  308.             These are bits set for those of the following
  309.             that need to be substituted into a standard
  310.             device node for this file system, lsb first:
  311.             e.g. 0x180 to substitute SegList & GlobalVec
  312.    fhb_Type      device node type: zero
  313.    fhb_Task      standard dos "task" field: zero
  314.    fhb_Lock      not used for devices: zero
  315.    fhb_Handler      filename to loadseg: zero placeholder
  316.    fhb_StackSize      stacksize to use when starting task
  317.    fhb_Priority      task priority when starting task
  318.    fhb_Startup      startup msg: zero placeholder
  319.    fhb_SegListBlocks   first of linked list of LoadSegBlocks:
  320.             Note that if the fhb_PatchFlags bit for this
  321.             entry is set (bit 7), the blocks pointed to by
  322.             this entry must be LoadSeg'd and the resulting
  323.             BPTR put in the FileSysEntry node.
  324.    fhb_GlobalVec      BCPL global vector when starting task
  325.             Zero or -1.
  326.    fhb_Reserved2      (those reserved by PatchFlags)
  327.  
  328.    fhb_Reserved3
  329.  
  330.  
  331.     LoadSegBlock
  332.       The end of data occurs when lsb_Next is null ($ffffffff), and
  333.       the summed data is exhausted.
  334.  
  335.    lsb_ID         == 'LSEG'
  336.    lsb_SummedLongs      size of this checksummed structure
  337.             Note that this is not 64 like most of the other
  338.             structures.  This is the number of valid longs
  339.             in this image, like bbb_SummedLongs.
  340.    lsb_ChkSum      block checksum (longword sum to zero)
  341.    lsb_HostID      SCSI Target ID of host
  342.             This describes the initiator ID for the creator
  343.             of these blocks.  (see the rdb_HostID
  344.             discussion)
  345.    lsb_Next      block number of the next LoadSegBlock
  346.    lsb_LoadData      data for "loadseg"
  347.             The data starts here and continues as long as
  348.             indicated by lsb_SummedLongs-5: e.g. if
  349.             lsb_SummedLongs is 128 (512 bytes), 123 longs
  350.             of data are valid here.
  351.  
  352. filesysres.[hi]
  353.  
  354.        The FileSysResource is created by the first code that needs to
  355.        use it.  It is added to the resource list for others to use.
  356.        (Checking and creation should be performed while Forbid()).
  357.  
  358.     FileSysResource
  359.    fsr_Node      on resource list
  360.    fsr_Creator      name of creator of this resource
  361.    fsr_FileSysEntries   list of FileSysEntry structs
  362.  
  363.     FileSysEntry
  364.    fse_Node      on fsr_FileSysEntries list
  365.             ln_Name is of creator of this entry
  366.    fse_DosType      DosType of this FileSys
  367.    fse_Version      release version of this FileSys
  368.             Usually MSW is version, LSW is revision.
  369.    fse_PatchFlags      bits set for those of the following that
  370.             need to be substituted into a standard
  371.             device node for this file system: e.g.
  372.             $180 for substitute SegList & GlobalVec
  373.    fse_Type      device node type: zero
  374.    fse_Task      standard dos "task" field
  375.    fse_Lock      not used for devices: zero
  376.    fse_Handler      filename to loadseg (if SegList is null)
  377.    fse_StackSize      stacksize to use when starting task
  378.    fse_Priority      task priority when starting task
  379.    fse_Startup      startup msg: FileSysStartupMsg for disks
  380.    fse_SegList      segment of code to run to start new task
  381.    fse_GlobalVec      BCPL global vector when starting task
  382.  
  383.    no more entries need exist than those implied by fse_PatchFlags, so
  384.    entries do not have a fixed size.
  385.  
  386.